An evolving tutorial.
N <- 10 # number of points
# latitude from -90 to +90
latitude <- runif(N, min = -90, max = 90)
# longitude from + -180 to + 180
longitude <- runif(N, min = -180, max = 180)
# 1st point reset to 0, 0
latitude[1] <- 0
longitude[1] <- 0
# label
label <- LETTERS[1:N] # label with letters of alphabet
# dataframe
mydata <- data.frame(latitude, longitude, label)
mydata # replay
latitude longitude label
1 0.00000 0.00000 A
2 84.26699 129.62778 B
3 -16.59724 -56.32133 C
4 27.35854 -92.25697 D
5 -55.60979 35.65833 E
6 74.41507 15.76868 F
7 -23.64852 -143.13018 G
8 72.11952 -55.33315 H
9 -33.78938 103.53958 I
10 -38.88660 -13.57762 J
mymap <- plot_geo(mydata) %>%
add_markers(x = ~longitude,
y = ~latitude,
color = ~label,
colors = "Spectral") %>%
layout(title = "Randomly Generated Coordinates")
mymap # replay